package idiet.dao.hibernate;

import idiet.bean.NurseTarget;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository("nurseTargetDao")
public class NurseTargetDao extends BaseDao {
	public NurseTarget getNurseTargetById(int palId){
		return (NurseTarget) this.sessionFactory
				.getCurrentSession()
				.createCriteria(NurseTarget.class)
				.add(Restrictions.eq("id", palId))
				.uniqueResult();
	}
	@SuppressWarnings("unchecked")
	public List<NurseTarget> getNurseTargetsByNurseTargetName(String nurseTargetName){
		return this.sessionFactory
				.getCurrentSession()
				.createCriteria(NurseTarget.class)
				.add(Restrictions.like("name",nurseTargetName))
				.list();
	}
	@SuppressWarnings("unchecked")
	public List<NurseTarget> getNurseTargets(){
		return this.sessionFactory
				.getCurrentSession()
				.createCriteria(NurseTarget.class)
				.list();
	}
	public void createNurseTarget(NurseTarget pal){
		this.sessionFactory
		.getCurrentSession()
		.save(pal);
	}
	public void updateNurseTarget(NurseTarget pal){
		this.sessionFactory
		.getCurrentSession()
		.update(pal);
	}
	public void deleteNurseTarget(NurseTarget pal){
		this.sessionFactory
		.getCurrentSession()
		.delete(pal);
	}
}
